<template>
  <div class="app-container">
    <PageSearch
      :showSearch.sync="showSearch"
      :getList="getList"
      :handleQuery="handleQuery"
      :resetQuery="resetQuery">
      <template #form>
        <el-form :model="queryParams" ref="queryForm" size="small">
          <el-row>
            <!-- <el-form-item prop="shopName">
              <el-input
                :placeholder="$t('店铺名称')"
                v-model="queryParams.shopName"
                clearable
                @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item prop="distrName">
              <el-input
                :placeholder="$t('租户名称')"
                v-model="queryParams.distrName"
                clearable
                @keyup.enter.native="handleQuery" />
            </el-form-item> -->
          </el-row>
        </el-form>
      </template>
      <template #actions> </template>
    </PageSearch>

    <el-table :height="calTableHeight()" ref="mianRef" v-loading="loading" :data="tableData">
      <el-table-column show-overflow-tooltip label="id" align="center" prop="id" />
      <el-table-column show-overflow-tooltip label="包裹号" align="center" prop="packageNo" />
      <el-table-column show-overflow-tooltip label="原数据" align="center" prop="originalData" />
      <el-table-column show-overflow-tooltip label="原数据hash值" align="center" prop="hash" />
      <el-table-column show-overflow-tooltip label="耗材ids" align="center" prop="cesIds" />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { listSkuConsumableRecommend } from '@/api/orderManage/skuConsumableRecommend'
export default {
  activated() {
    this.$nextTick(() => this.$refs['mianRef']?.doLayout())
  },
  name: 'MercariPersonalSync',
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,

      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 供应厂家表格数据
      tableData: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询供应厂家列表 */
    getList() {
      this.loading = true
      listSkuConsumableRecommend(this.queryParams).then((response) => {
        this.tableData = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      Object.keys(this.queryParams).forEach((key) => (this.queryParams[key] = ''))
      this.queryParams.pageSize = 10
      this.queryParams.pageNum = 1
      this.handleQuery()
    },
  },
}
</script>
